#ifndef DDEBUG_H
#define DDEBUG_H

#ifndef __model__
#define __model__ "rds-json"
#endif

#include "ddefine.h"

#if defined(DDEBUG) && (DDEBUG)

#define dd_dump_chain_size() { \
        int n; \
        ngx_chain_t *cl; \
        for (n = 0, cl = ctx->out; cl; cl = cl->next, n++) { \
        } \
        dd("chain size: %d", n); \
    }

#define dd_check_read_event_handler(r)   \
    dd("r->read_event_handler = %s", \
        r->read_event_handler == ngx_http_block_reading ? \
            "ngx_http_block_reading" : \
        r->read_event_handler == ngx_http_test_reading ? \
            "ngx_http_test_reading" : \
        r->read_event_handler == ngx_http_request_empty_handler ? \
            "ngx_http_request_empty_handler" : "UNKNOWN")

#define dd_check_write_event_handler(r)   \
    dd("r->write_event_handler = %s", \
        r->write_event_handler == ngx_http_handler ? \
            "ngx_http_handler" : \
        r->write_event_handler == ngx_http_core_run_phases ? \
            "ngx_http_core_run_phases" : \
        r->write_event_handler == ngx_http_request_empty_handler ? \
            "ngx_http_request_empty_handler" : "UNKNOWN")

#else

#define dd_dump_chain_size()
#define dd_check_read_event_handler(r)
#define dd_check_write_event_handler(r)

#endif

#endif /* DDEBUG_H */

